﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core
{
    public class NodeTypeInterfaceImplementation : SubEntity<NodeTypeInterfaceImplementation, NodeType>
    {
        internal NodeTypeInterfaceImplementation(Guid id, Guid typeId, Guid interfaceId)
            : base(id)
        {
            InterfaceId = interfaceId;
            OwnerId = typeId;
            Status = EntityStates.Loaded;
        }

        public NodeTypeInterfaceImplementation(Guid typeId, Guid interfaceId)
        {
            OwnerId = typeId;
            Status = EntityStates.New;
            InterfaceId = interfaceId;
        }

        public Guid InterfaceId { get; internal set; }

        private NodeTypeInterface _nodeTypeInterface;
        public NodeTypeInterface NodeTypeInterface
        {
            get
            {
                if (_nodeTypeInterface == null)
                    _nodeTypeInterface = NodeTypeManager.GetNodeTypeInterface(InterfaceId);

                return _nodeTypeInterface;
            }
        }

        protected override NodeType GetOwner(Guid ownerId)
        {
            return NodeTypeManager.GetNodeType(ownerId);
        }
    }
}
